<?php


abstract class BaseBuyData extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $name;


	
	protected $category;


	
	protected $price;


	
	protected $quantity;


	
	protected $date_year;


	
	protected $date_month;


	
	protected $date_day;


	
	protected $member;


	
	protected $send_flg;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getName()
	{

		return $this->name;
	}

	
	public function getCategory()
	{

		return $this->category;
	}

	
	public function getPrice()
	{

		return $this->price;
	}

	
	public function getQuantity()
	{

		return $this->quantity;
	}

	
	public function getDateYear()
	{

		return $this->date_year;
	}

	
	public function getDateMonth()
	{

		return $this->date_month;
	}

	
	public function getDateDay()
	{

		return $this->date_day;
	}

	
	public function getMember()
	{

		return $this->member;
	}

	
	public function getSendFlg()
	{

		return $this->send_flg;
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = BuyDataPeer::ID;
		}

	} 
	
	public function setName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = BuyDataPeer::NAME;
		}

	} 
	
	public function setCategory($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->category !== $v) {
			$this->category = $v;
			$this->modifiedColumns[] = BuyDataPeer::CATEGORY;
		}

	} 
	
	public function setPrice($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->price !== $v) {
			$this->price = $v;
			$this->modifiedColumns[] = BuyDataPeer::PRICE;
		}

	} 
	
	public function setQuantity($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->quantity !== $v) {
			$this->quantity = $v;
			$this->modifiedColumns[] = BuyDataPeer::QUANTITY;
		}

	} 
	
	public function setDateYear($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->date_year !== $v) {
			$this->date_year = $v;
			$this->modifiedColumns[] = BuyDataPeer::DATE_YEAR;
		}

	} 
	
	public function setDateMonth($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->date_month !== $v) {
			$this->date_month = $v;
			$this->modifiedColumns[] = BuyDataPeer::DATE_MONTH;
		}

	} 
	
	public function setDateDay($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->date_day !== $v) {
			$this->date_day = $v;
			$this->modifiedColumns[] = BuyDataPeer::DATE_DAY;
		}

	} 
	
	public function setMember($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->member !== $v) {
			$this->member = $v;
			$this->modifiedColumns[] = BuyDataPeer::MEMBER;
		}

	} 
	
	public function setSendFlg($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->send_flg !== $v) {
			$this->send_flg = $v;
			$this->modifiedColumns[] = BuyDataPeer::SEND_FLG;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->name = $rs->getString($startcol + 1);

			$this->category = $rs->getInt($startcol + 2);

			$this->price = $rs->getInt($startcol + 3);

			$this->quantity = $rs->getInt($startcol + 4);

			$this->date_year = $rs->getInt($startcol + 5);

			$this->date_month = $rs->getInt($startcol + 6);

			$this->date_day = $rs->getInt($startcol + 7);

			$this->member = $rs->getString($startcol + 8);

			$this->send_flg = $rs->getString($startcol + 9);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating BuyData object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(BuyDataPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			BuyDataPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(BuyDataPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = BuyDataPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += BuyDataPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = BuyDataPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = BuyDataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getCategory();
				break;
			case 3:
				return $this->getPrice();
				break;
			case 4:
				return $this->getQuantity();
				break;
			case 5:
				return $this->getDateYear();
				break;
			case 6:
				return $this->getDateMonth();
				break;
			case 7:
				return $this->getDateDay();
				break;
			case 8:
				return $this->getMember();
				break;
			case 9:
				return $this->getSendFlg();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = BuyDataPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getCategory(),
			$keys[3] => $this->getPrice(),
			$keys[4] => $this->getQuantity(),
			$keys[5] => $this->getDateYear(),
			$keys[6] => $this->getDateMonth(),
			$keys[7] => $this->getDateDay(),
			$keys[8] => $this->getMember(),
			$keys[9] => $this->getSendFlg(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = BuyDataPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setCategory($value);
				break;
			case 3:
				$this->setPrice($value);
				break;
			case 4:
				$this->setQuantity($value);
				break;
			case 5:
				$this->setDateYear($value);
				break;
			case 6:
				$this->setDateMonth($value);
				break;
			case 7:
				$this->setDateDay($value);
				break;
			case 8:
				$this->setMember($value);
				break;
			case 9:
				$this->setSendFlg($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = BuyDataPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCategory($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setQuantity($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setDateYear($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setDateMonth($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setDateDay($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setMember($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setSendFlg($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(BuyDataPeer::DATABASE_NAME);

		if ($this->isColumnModified(BuyDataPeer::ID)) $criteria->add(BuyDataPeer::ID, $this->id);
		if ($this->isColumnModified(BuyDataPeer::NAME)) $criteria->add(BuyDataPeer::NAME, $this->name);
		if ($this->isColumnModified(BuyDataPeer::CATEGORY)) $criteria->add(BuyDataPeer::CATEGORY, $this->category);
		if ($this->isColumnModified(BuyDataPeer::PRICE)) $criteria->add(BuyDataPeer::PRICE, $this->price);
		if ($this->isColumnModified(BuyDataPeer::QUANTITY)) $criteria->add(BuyDataPeer::QUANTITY, $this->quantity);
		if ($this->isColumnModified(BuyDataPeer::DATE_YEAR)) $criteria->add(BuyDataPeer::DATE_YEAR, $this->date_year);
		if ($this->isColumnModified(BuyDataPeer::DATE_MONTH)) $criteria->add(BuyDataPeer::DATE_MONTH, $this->date_month);
		if ($this->isColumnModified(BuyDataPeer::DATE_DAY)) $criteria->add(BuyDataPeer::DATE_DAY, $this->date_day);
		if ($this->isColumnModified(BuyDataPeer::MEMBER)) $criteria->add(BuyDataPeer::MEMBER, $this->member);
		if ($this->isColumnModified(BuyDataPeer::SEND_FLG)) $criteria->add(BuyDataPeer::SEND_FLG, $this->send_flg);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(BuyDataPeer::DATABASE_NAME);

		$criteria->add(BuyDataPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setName($this->name);

		$copyObj->setCategory($this->category);

		$copyObj->setPrice($this->price);

		$copyObj->setQuantity($this->quantity);

		$copyObj->setDateYear($this->date_year);

		$copyObj->setDateMonth($this->date_month);

		$copyObj->setDateDay($this->date_day);

		$copyObj->setMember($this->member);

		$copyObj->setSendFlg($this->send_flg);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new BuyDataPeer();
		}
		return self::$peer;
	}

} 